import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:verse_systems/res/colors.dart';
import 'package:verse_systems/widgets/back_button.dart';
import 'package:verse_systems/widgets/round_underline_tabIndicator.dart';

class CustomGradeAppbar extends StatelessWidget implements PreferredSizeWidget {
  const CustomGradeAppbar(
      {super.key, required this.tabController, required this.tabs});

  final TabController tabController;
  final List<Map> tabs;

  @override
  Widget build(BuildContext context) {
    return AppBar(
        backgroundColor: Colours.app_main_color,
        title: TabBar(
          controller: tabController, // 联动控制器
          tabs: tabs.map((item) {
            return Tab(text: item["title"]);
          }).toList(),
          indicator: const RoundUnderlineTabIndicator(
              borderSide: BorderSide(
            width: 3.5,
            color: Colours.app_main_background_color,
          )),
          isScrollable: true,
          labelColor: Colours.course_file_text_color,
          labelStyle: TextStyle(fontSize: 15.sp, fontWeight: FontWeight.bold),
          unselectedLabelColor: Colours.sub_title_color,
          unselectedLabelStyle: TextStyle(fontSize: 13.sp),
          enableFeedback: true, // 是否启动点击反馈
          onTap: (int value) {
            debugPrint("hahahahahah====$value");
          },
        ),
        elevation: 0.4,
        centerTitle: true,
        systemOverlayStyle: SystemUiOverlayStyle.dark,
        leading: IosBackButton(
          color: Colours.drawer_text_color,
          size: 16.w,
        ));
  }

  @override
  Size get preferredSize => Size.fromHeight(50.w);
}
